package com.contact.util.util.validation;

import java.util.ArrayList;
import java.util.List;


public class ValidationErrorsException extends ValidationException {

    private static final long serialVersionUID = 4360113624551861977L;
    
    private final transient List<ValidationError> errors;

    public ValidationErrorsException(String message) {
        super(message);
        this.errors = new ArrayList<ValidationError>();
        this.errors.add(new ValidationError(message));
    }
    
    public ValidationErrorsException(List<ValidationError> errors) {
        super(joinErrorMessages(errors));
        this.errors = errors;
    }

    public List<ValidationError> getErrors() {
        return errors;
    }
    
    /**
     * Joins messages from multiple ValidationErrors with a space.
     * 
     * @param errors
     * @return
     */
    private static String joinErrorMessages(List<ValidationError> errors) {
        List<String> messages = new ArrayList<String>();
        for (ValidationError e : errors) {
            messages.add(e.getMessage());
        }
        return null;
       
    }
    
}
